Skip to content

enh: Add support for synthetic legends on ImageStackPlot#6662

Merged
hoxbro merged 10 commits into
mainfrom
cat_legend_fix
Aug 15, 2025
Merged

enh: Add support for synthetic legends on ImageStackPlot#6662
hoxbro merged 10 commits into
mainfrom
cat_legend_fix

Conversation

@philippjfr

@philippjfr philippjfr commented Aug 12, 2025

Copy link
Copy Markdown
Member
  • Enh: The same handling that allowed us to create a synthetic legend on an RGB plot can trivially be extended to generate a legend for an ImageStackPlot created from a rasterize operation.
  • Fix: Ensures categorical legend does not error when len(categories) > len(colors).

@philippjfr philippjfr changed the title Fix categorical RGB legend when len(categories) > len(colors) fix: Fix categorical RGB legend when len(categories) > len(colors) Aug 12, 2025
@philippjfr philippjfr added the type: bug Something isn't correct or isn't working label Aug 12, 2025
@codecov

codecov Bot commented Aug 12, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.92308% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.95%. Comparing base (e767feb) to head (7ef58a8).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
holoviews/plotting/bokeh/raster.py 89.47% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6662      +/-   ##
==========================================
+ Coverage   88.92%   88.95%   +0.02%     
==========================================
  Files         328      328              
  Lines       70040    70078      +38     
==========================================
+ Hits        62283    62335      +52     
+ Misses       7757     7743      -14     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread holoviews/plotting/util.py Outdated
@philippjfr philippjfr changed the title fix: Fix categorical RGB legend when len(categories) > len(colors) enh: Add support for synthetic legends on ImageStackPlot Aug 12, 2025
@hoxbro
hoxbro self-requested a review August 12, 2025 12:44
Comment thread holoviews/plotting/util.py Outdated
shade_op = element.pipeline.find(shade, skip_nonlinked=False)
if shade_op is None:
if self.p.cmap is None:
colors = ds.colors.Sets1to3

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we make this the default of cmap? Even if we need to copy the list over.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in a37d653

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, this should simply inherit the default cmap for that particular plot class. Will look at that.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hadn't reloaded the page, your changes are fine.

Comment thread holoviews/plotting/bokeh/raster.py Outdated
@hoxbro hoxbro removed the type: bug Something isn't correct or isn't working label Aug 15, 2025
@hoxbro
hoxbro merged commit 727eab6 into main Aug 15, 2025
14 checks passed
@hoxbro
hoxbro deleted the cat_legend_fix branch August 15, 2025 09:56
@maximlt

maximlt commented Aug 18, 2025

Copy link
Copy Markdown
Member

Doesn't this resolve some of the issues mentioned in #6638?

@github-actions

github-actions Bot commented Dec 2, 2025

Copy link
Copy Markdown
Contributor

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Dec 2, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants